/*-------------------------------------
		sPlugin
	    By Scooby, 2010
-------------------------------------*/

local PLUGIN = {}

PLUGIN.Name = "Add Group"
PLUGIN.Author = "Scooby"
PLUGIN.Command = "addgroup"
PLUGIN.Group = 0
PLUGIN.Category = "Group"
PLUGIN.Use = "<Name> <Rank> <Immunity>"
PLUGIN.Format = "string number number"
PLUGIN.Menu = { 
	{ 
		["#title"] = "Select Name", 
		["#cont"] = "#text", 
		["#apos"] = 1 
	}, 
	{ 
		["#title"] = "Select Rank", 
		["#cont"] = "#number", 
		["#apos"] = 2 
	}, 
	{ 
		["#title"] = "Select Immunity", 
		["#cont"] = "#number", 
		["#apos"] = 3 
	}
}
		

function PLUGIN:Init()
	
	if( !spl.groups ) then -- DO NOT EDIT THIS, THIS IS DEFAULT GROUPS, USE IN GAME MENU!
		
		local guest = {}
			guest.Name = "Guest"
			guest.Immunity = 1
			guest.Rank = 3
			
		local moderator = {}
			moderator.Name = "Moderator"
			moderator.Immunity = 2
			moderator.Rank = 2
		
		local admin = {}
			admin.Name = "Admin"
			admin.Immunity = 3
			admin.Rank = 1
		
		local superadmin = {}
			superadmin.Name = "SuperAdmin"
			superadmin.Immunity = 4
			superadmin.Rank = 0
			
		spl:RegisterGroup( guest )
		spl:RegisterGroup( moderator )
		spl:RegisterGroup( admin )
		spl:RegisterGroup( superadmin )
		
		spl.info.alevel = 1
		spl.info.salevel = 0
		
		spl:SaveInfo()
		
	end

end

function PLUGIN:Main( ply, args )
	
	if( spl:GroupExists( args[1] ) ) then
		spl:PrintC( ply, spl.red, "That Group Already Exists!" )
		
	else
	
		local group = {}
			group.Name = tostring( args[1] )
			group.Rank = tonumber( args[2] )
			group.Immunity = tonumber( args[3] )
			
		if( group.Rank == 0 ) then
			spl:PrintC( spl.red, "Rank Has To Be Greater Than 0" )
		else
			spl:RegisterGroup( group )
		
			spl:PrintC( ply, spl.green, "Group '"..group.Name.."' Added, Rank : "..group.Rank.."  Immunity : "..group.Immunity )
		end
		
	end
end

spl:AddPlugin( PLUGIN )